<template>
  <div class>
    <nly-container :fluid="true">
      <nly-breadcrumb>
        <nly-breadcrumb-item
          icon="nlyfont nly-icon-home-fill"
          to="/"
          text="首页"
        />
        <nly-breadcrumb-item
          icon="nlyfont nly-icon-outlet"
          to="/food"
          active
          text="优惠卡订单管理"
        />
      </nly-breadcrumb>

      <section class="content">
        <row>
          <i-col :md="6" :sm="8">
            <Input
              v-model="searchText"
              search
              placeholder="根据用户昵称"
              enter-button="搜索"
              @on-search="search(searchText)"
            />
          </i-col>
          <Select
            v-model="data.cb_type"
            @on-change="change_type"
            style="width: 200px; margin-left: 26px"
            placeholder="请选择优惠卡类型"
          >
            <Option :value="7">全部</Option>
            <Option :value="0">舞蹈室通用卡</Option>
            <Option :value="1">A舞蹈室专属卡</Option>
            <Option :value="2">B舞蹈室专属卡</Option>
            <Option :value="3">C舞蹈室专属卡</Option>
            <Option :value="4">D舞蹈室专属卡</Option>
            <Option :value="5">课程专属卡</Option>
            <Option :value="6">私教专属卡</Option>
          </Select>
        </row>
        <br />
        <Table
          border
          :columns="header"
          :data="accountList"
          @on-selection-change="enterall"
          ref="selection"
        >
        <template slot-scope="{ row }" slot="avatar">
            <img :src="row.avatar" class="avatar" />
          </template>
        </Table>
        <br />
        <div class="Page">
          <Page
            :total="total"
            show-elevator
            show-total
            :page-size="data.pageSize"
            :current="data.page"
            @on-change="changePage"
          />
        </div>
      </section>
    </nly-container>
  </div>
</template>
<script>
import apis from "@/api/category";
export default {
  components: {},
  data() {
    return {
      modalAddText: false,
      update: false,
      searchText: "",
      total: 0, //数据条数
      data: {
        page: 1, //当前页
        pageSize: 10, //每页显示个数
        cb_type: 7,
        par: "",
      },
      header: [
        {
          title: "用户昵称",
          key: "nickname",
          align: "center",
        },
         {
          title: "头像",
          slot: "avatar",
          key: "avatar",
          align: "center"
        },
        {
          title: "优惠卡类型",
          key: "cb_name",
          align: "center",
        },
        {
          title: "订单号",
          key: "out_trade_no",
          align: "center",
        },
        {
          title: "支付金额",
          key: "uc_price",
          align: "center",
        },
        

        {
          title: "总次数/时长(小时)",
          key: "uc_knum",
          align: "center",
        },
        {
          title: "有效期(月)",
          key: "uc_valid",
          align: "center",
        },
        {
          title: "下单时间",
          key: "uc_time",
          align: "center",
        },
      ],
      accountList: [],
      count_scale: [],
      pageNow: 1,
      selectclass: [],

      key: "",
    };
  },
  mounted() {
    let that = this;
    that.getcardlist();
  },
  methods: {
    change_adm_area(val) {
      this.dataText.cb_type = "";
      this.dataText.cb_type = val;
    },
    change_type(val) {
      console.log(val);
      this.data.cb_type = "";
      this.data.cb_type = val;
      this.getcardlist();
    },
    addShow() {
      this.modalAddText = true;
    },
    enterall(e) {
      this.enteralldata = e;
      console.log(e);
    },
    remove(id) {
      let cb_id = "";
      if (id) {
        cb_id = id;
      } else {
        this.enteralldata.map((itme) => {
          if (cb_id == "") {
            cb_id = itme.cb_id;
          } else {
            cb_id += "," + itme.cb_id;
          }
        });
      }
      apis
        .deletecard({ cb_id: cb_id })
        .then((response) => {
          console.log(response);
          if (response.data.code == 200) {
            this.$Message.success("删除成功");
            this.getcardlist();
          } else {
            this.$Message.error("删除失败!");
          }
        })
        .catch((error) => {
          console.log(error);
          this.loading = false;
          this.$Message.error("删除失败!");
        });
    },
    getcardlist() {
      let that = this;
      apis.getcardorder(this.data).then((response) => {
        let resdata = response.data;
        if (resdata.code == 200) {
          console.log(response.data);
          that.accountList = resdata.data.depts;
          that.total = response.data.data.countNumber;
        }
      });
    },
    changePage(page) {
      this.data.page = page;
      this.getcardlist();
    },
    search(val) {
      this.data.page = 1;
      let data = this.data;
      data.par = val;
      this.getcardlist();
    },
  },
};
</script>

<style scoped>
.padding20 {
  margin: 20px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 90px;
  margin: 5px;
}
.Page {
  display: flex;
  justify-content: center;
  text-align: center;
  padding-bottom: 10px;
}
.ivu-modal-body {
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
</style>